package dao

import (
	"yundian/internel/app/models/options"
	"yundian/internel/pkg/dingo"
	"yundian/internel/pkg/dingo/global"
)

// -------------------- dao层 - 配置相关操作 -----------------------//

type OptionsDao struct {
}

func NewOptionsDao() *OptionsDao {
	return &OptionsDao{}
}

//
func (d *OptionsDao) UpdateOptions(key string, value string) *dingo.ErrorWrap {
	m := options.New()
	db := global.Orm.Model(m).Table("options").Where("option_key = ?", key).Update("option_value", value)
	return dingo.ErrorIf(db.Error, true)
}
